package com.fenghongzhang.day001;


import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.fenghongzhang.day001.R;

public class Main2Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
    }

    /**
     * 1.自定义类继承Dialog
     * 2.重写Dialog的方法并添加需要的功能
     * 3.在Activity中实例化自定义类的对象
     * @param view
     */
    public void click(View view) {
        //自定义对话

        MyDialog myDialog = new MyDialog(this);

        myDialog.setTitleStr("hehe");
        //外部使用
        myDialog.setMessageStr("改吃吃,改玩玩");

        //5,外部调用
        myDialog.setOnYesClick(new MyDialog.OnYesClick() {
            @Override
            public void onClick() {
                Toast.makeText(Main2Activity.this, "hehehe", Toast.LENGTH_SHORT).show();
            }
        });
        
        myDialog.setOnNoClick(new MyDialog.OnNoClick() {
            @Override
            public void onClick() {
                Toast.makeText(Main2Activity.this, "点了取消", Toast.LENGTH_SHORT).show();
            }
        });

        //继承来的
        myDialog.show();
    }
}
